import ErrorPlugin from './errorPlugin'
import Vue from 'vue'
Vue.use(ErrorPlugin)

import Cookies from 'js-cookie'

import 'normalize.css/normalize.css'

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/zh-CN'

import '@/styles/index.scss' // global css

import FormMaking from 'form-making'
import 'form-making/dist/FormMaking.css'
import Viewer from 'v-viewer'
import 'viewerjs/dist/viewer.css'
import VECharts from 'vue-echarts/components/ECharts'
import 'echarts/lib/chart/bar'
import 'echarts/lib/chart/line'
import 'echarts/lib/component/visualMap'
import echarts from 'echarts/lib/echarts'
import wland from '@/styles/echart/theme/wonderland.json'
// import FormMaking from 'form-making-advanced'
// import 'form-making-advanced/dist/FormMaking.css'

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control
import { getDicts, formatDictText, removeObjWithArr, isObjectValueEqual, getCurDate, isEmpty } from '@/utils/util'

import permission from './directive/permission/permission'

// 开发环境若需要走mock挡板，将注释去掉即可 development-开发 production-生产
// import {mockXHR} from '../mock'
if (process.env.NODE_ENV === 'development') {
  // mockXHR()
}

echarts.registerTheme('wonderland', wland)
const size = Cookies.get('size') || 'mini'
Vue.component('chart', VECharts)
Vue.use(ElementUI, { locale, size })
Vue.use(FormMaking)
Vue.use(Viewer, {
  defaultOptions: {
    zIndex: 9999
  }
})
Vue.directive('permission', permission)

Vue.config.productionTip = false
Vue.prototype.getDicts = getDicts
Vue.prototype.formatDictText = formatDictText
Vue.prototype.isObjectValueEqual = isObjectValueEqual
Vue.prototype.removeObjWithArr = removeObjWithArr
Vue.prototype.isEmpty = isEmpty
Vue.prototype.getCurDate = getCurDate

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
